﻿using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;

namespace CricketCheat
{
    [HarmonyPatch(typeof(UI_CatchCricket), "OnClickCatchPlace")]
    class OnClickCatchPlace
    {
		public static IEnumerable<CodeInstruction> Transpiler(MethodBase __originalMethod, IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction i in instructions)
			{
				if (Main.SingLevel && i.opcode == OpCodes.Call && ((MethodInfo)(i.operand)).Name.Contains("AddMethodCall"))
				{
					i.operand = typeof(OnClickCatchPlace).GetMethod("catch_all");
				}
				yield return i;
			}
		}
		public static void catch_all(int listenerId, ushort domainId, ushort methodId, short arg1, short arg2, short arg3, sbyte arg4)
		{
			GLog.Log("增加抓捕概率");
			GameData.GameDataBridge.GameDataBridge.AddMethodCall<short, short, short, sbyte>(listenerId, domainId, methodId, arg1, arg2, 30000, arg4);
		}
	}
}
